/**
 * @fileOverview The "liststyle" plugin.
 */
(function() {
   VED.plugins.liststyle = {
      requires: 'dialog,contextmenu',
      lang: 'en,ru', // %REMOVE_LINE_CORE%
      init: function( editor ) {
         if ( editor.blockless )
            return;

         var def, cmd;

         def = new VED.dialogCommand( 'numberedListStyle', {
            requiredContent: 'ol',
            allowedContent: 'ol{list-style-type}[start]'
         } );
         cmd = editor.addCommand( 'numberedListStyle', def );
         editor.addFeature( cmd );
         VED.dialog.add( 'numberedListStyle', this.path + 'dialogs/liststyle.js' );

         def = new VED.dialogCommand( 'bulletedListStyle', {
            requiredContent: 'ul',
            allowedContent: 'ul{list-style-type}'
         } );
         cmd = editor.addCommand( 'bulletedListStyle', def );
         editor.addFeature( cmd );
         VED.dialog.add( 'bulletedListStyle', this.path + 'dialogs/liststyle.js' );

         //Register map group;
         editor.addMenuGroup( "list", 108 );

         editor.addMenuItems({
            numberedlist: {
               label: editor.lang.liststyle.numberedTitle,
               group: 'list',
               command: 'numberedListStyle'
            },
            bulletedlist: {
               label: editor.lang.liststyle.bulletedTitle,
               group: 'list',
               command: 'bulletedListStyle'
            }
         });

         editor.contextMenu.addListener( function( element, selection ) {
            if ( !element || element.isReadOnly() )
               return null;

            while ( element ) {
               var name = element.getName();
               if ( name == 'ol' )
                  return { numberedlist: VED.TRISTATE_OFF };
               else if ( name == 'ul' )
                  return { bulletedlist: VED.TRISTATE_OFF };

               element = element.getParent();
            }
            return null;
         });
      }
   };

   VED.plugins.add( 'liststyle', VED.plugins.liststyle );
})();






